package leetcode.cn;

/**
 * @version 1.8
 * @Author Djx_hmbb
 * @Date 2023/8/8 12:00
 * @注释:
 */
public class Day02 {
    public static void main(String[] args) {
        int[][] grid = {{6,0,0,0,0,0,0,18},{0,17,0,0,0,0,18,0},{0,0,13,0,0,17,0,0},{0,0,0,9,18,0,0,0},{0,0,0,2,20,0,0,0},{0,0,20,0,0,3,0,0},{0,14,0,0,0,0,11,0},{19,0,0,0,0,0,0,9}};
        boolean b = checkXMatrix(grid);
        System.out.println(b);
    }

    //判断是否构成x型
    public static boolean checkXMatrix(int[][] grid) {
        for(int i = 0;i<grid.length;i++){
            for(int j = 0;j<grid.length;j++){
                if(i == j && grid[i][j] == 0){
                    return false;
                }
                if(i+j == (grid.length-1) && grid[i][j] == 0){
                    return false;
                }
                if(i != j && i+j != (grid.length-1) && grid[i][j] != 0){
                    return false;
                }
            }
        }
        return true;
    }
}
